//
//  RNOLUseCouponRedBagCell.m
//  RongNiuOnline
//
//  Created by apple on 2018/5/21.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLUseCouponRedBagCell.h"

@interface RNOLUseCouponRedBagCell()

@property (weak, nonatomic) IBOutlet UILabel *limitLabel;

@property (weak, nonatomic) IBOutlet UILabel *originLabel;

@property (weak, nonatomic) IBOutlet UILabel *couponMoneyLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;

@property (weak, nonatomic) IBOutlet UIButton *flagButton;

@property (weak, nonatomic) IBOutlet UIImageView *bgImageView;

@end


@implementation RNOLUseCouponRedBagCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.flagButton.userInteractionEnabled = NO ;
    
}

- (void)setIsRedBag:(BOOL)isRedBag{
    _isRedBag = isRedBag;
    
    [self.flagButton setTitleColor: (isRedBag? kRedBagColor : kAppMainColor)  forState: UIControlStateSelected];
    self.bgImageView.image = isRedBag? [UIImage imageNamed:@"rnol_redbag_bg_avable"] :  [UIImage imageNamed:@"rnol_addvalue_bg_avable"] ;
    self.couponMoneyLabel.textColor = isRedBag? kRedBagColor : kAppMainColor;
    
    if (isRedBag) {
        NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"100元"];
        NSDictionary *dict = @{NSFontAttributeName : KFontSize(28),NSForegroundColorAttributeName : kRedBagColor};
        NSRange range = NSMakeRange(0, @(100).stringValue.length);
        [attStr addAttributes:dict range: range];
        self.couponMoneyLabel.attributedText = attStr;
    }else{
        NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"1.2%加息"];
        NSDictionary *dict = @{NSFontAttributeName : KFontSize(28),NSForegroundColorAttributeName : kAppMainColor};
        NSRange range = NSMakeRange(0, @"1.2%".length);
        [attStr addAttributes:dict range: range];
        self.couponMoneyLabel.attributedText = attStr;
    }
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
     self.flagButton.selected = selected;
    if (self.flagButton.selected) {
        self.flagButton.layer.borderColor = self.isRedBag? kRedBagColor.CGColor : kAppMainColor.CGColor;
    }else{
        self.flagButton.layer.borderColor = kTextLightGrayColor.CGColor;
    }

}

@end
